package impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;

import dao.*;
import model.*;

public class ComisionDAOImpl implements ComisionDAO{

	private HibernateTemplate hibernateTemplate = null;
	
	@Override
	public List<Comision> getAll() {
		return this.hibernateTemplate.loadAll(Comision.class);
	}

	@Override
	public Comision getById(Integer comisionID) {
		return this.hibernateTemplate.get(Comision.class, comisionID);
	}

	@Override
	public void update(Comision comision) {
		this.hibernateTemplate.update(comision);
	}

	@Override
	public void delete(Integer comisionID) {
		this.hibernateTemplate.delete(comisionID);
	}

	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory){
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}

	@Override
	public void save(Comision comision) {
		this.hibernateTemplate.save(comision);		
	}

}
